﻿#region NeoPatterns
// 
// NeoPatterns framework is released under LGPLv3 license.
// See http://www.opensource.org/licenses/lgpl-3.0.html for more details.
// 
// Please visit http://neopatterns.wikidot.com for more information about NeoPatterns
// 
// Copyright (c) Pascal Craponne 2008
// 
#endregion

namespace NeoPatterns.Patterns.Proxy
{
    /// <summary>
    /// A proxy adapter allows to change proxy for a specific instance
    /// </summary>
    public class AspectProxy : IProxy
    {
        /// <summary>
        /// Gets or set the actual target
        /// </summary>
        public object Target
        {
            get { return ProxyAdvisor.GetTarget(Proxy); }
            set { ProxyAdvisor.SetTarget(Proxy, value); }
        }

        /// <summary>
        /// The proxy object
        /// </summary>
        public object Proxy { get; private set; }
        /// <summary>
        /// The proxy advisor
        /// </summary>
        public ProxyAdvisor ProxyAdvisor { get; private set; }

        public AspectProxy(object proxy, ProxyAdvisor proxyAdvisor)
        {
            Proxy = proxy;
            ProxyAdvisor = proxyAdvisor;
        }
    }
}